package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.ExpProjectReq;
import com.softer.wxzj.entity.ExpSurveyInfo;
import com.softer.wxzj.service.ExpSurveyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 现场勘查
 *
 * @author liu jinming
 * @date 2019/8/17
 */
@RestController
@RequestMapping("/expSurveyInfo")
public class ExpSurveyInfoController {
    @Autowired
    private ExpSurveyInfoService expSurveyInfoService;

    /**
     * 新增现场勘查
     *
     * @param expSurveyInfo 现场勘查
     * @return 结果
     */
    @PostMapping("/add")
    @LogRecord(description = "新增现场勘查", operationUnit = LogOperationUnit.EXP_PROJECT_REQ, operationType = LogOperationType.INSERT)
    public CommonResult add(@RequestBody ExpSurveyInfo expSurveyInfo) {
        return expSurveyInfoService.add(expSurveyInfo);
    }

    /**
     * 修改现场勘查
     *
     * @param expSurveyInfo 现场勘查
     * @return 结果
     */
    @PostMapping("/update")
    @LogRecord(description = "修改现场勘查", operationUnit = LogOperationUnit.EXP_PROJECT_REQ, operationType = LogOperationType.UPDATE)
    public CommonResult update(@RequestBody ExpSurveyInfo expSurveyInfo) {
        return expSurveyInfoService.update(expSurveyInfo);
    }

    /**
     * 刪除现场勘查
     *
     * @param id 现场勘查ID
     * @return 结果
     */
    @PostMapping("/delete")
    @LogRecord(description = "刪除现场勘查", operationUnit = LogOperationUnit.EXP_PROJECT_REQ, operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return expSurveyInfoService.delete(id);
    }

    /**
     * 查詢现场勘查
     *
     * @param id 现场勘查ID
     * @param arcType 图档大类
     * @return 现场勘查详情
     */
    @PostMapping("/getInfo")
    @LogRecord(description = "查詢现场勘查详情", operationUnit = LogOperationUnit.EXP_PROJECT_REQ, operationType = LogOperationType.SELECT)
    public ExpSurveyInfo getInfo(String id, String arcType) {
        return expSurveyInfoService.getInfo(id,arcType);
    }

    /**
     * 查询所有勘查记录
     * @param expSurveyInfo 查询实体
     * @return 列表
     */
    @PostMapping("/getAllList")
    @LogRecord(description = "查询项目的勘查记录", operationUnit = LogOperationUnit.EXP_PROJECT_REQ, operationType = LogOperationType.SELECT)
    public List<ExpSurveyInfo> getAllList(ExpSurveyInfo expSurveyInfo) {
        return expSurveyInfoService.getAllList(expSurveyInfo);
    }

    /**
     * 现场勘查列表
     *
     * @param page          分页实体
     * @param expProjectReq 查询实体
     * @return 列表
     */
    @PostMapping("/getProjectList")
    @LogRecord(description = "现场勘查列表", operationUnit = LogOperationUnit.EXP_PROJECT_REQ, operationType = LogOperationType.SELECT)
    public PageInfo<ExpProjectReq> getProjectList(Page page, ExpProjectReq expProjectReq) {
        return expSurveyInfoService.getProjectList(page, expProjectReq);
    }

}
